﻿<ul class="kui-app-menu">
    @if (Items != null && Items.Count > 0)
    {
        foreach (var item in Items)
        {
            <li @onclick="e=>OnItemClick(item)" style="width:@(Width)%">
                <div class="kui-app-menu-icon" style="background-color:@item.Color">
                    <Icon Type="@item.Icon" Theme="outline" />
                </div>
                <div>@item.Name</div>
            </li>
        }
    }
</ul>

@code {
    private double Width => 100 / Count;

    [Parameter] public int Count { get; set; } = 2;
    [Parameter] public List<Known.MenuItem> Items { get; set; }
    [Parameter] public Action<Known.MenuItem> OnClick { get; set; }

    private void OnItemClick(Known.MenuItem item) => OnClick?.Invoke(item);
}